﻿using System;
using System.Drawing;
using BlueDot.Mobile.Core;
using NavigationSample.UI;

namespace NavigationSample
{
    public class MainWorkflow : ViewWorkflow
    {
        #region Events

        [Sender("action://MainWorkflow/MoveToNextWorkflow")]
        public event EventHandler MoveToNextWorkflow;

        #endregion

        #region Constructors

        public MainWorkflow()
        {
            InitializeComponent();
        }

        [DependencyConstructor]
        public MainWorkflow(IMobileApplication application)
            : base(application)
        {
            InitializeComponent();
        }

        #endregion

        #region public

        [Receiver("action://Step5/nextButton/Click")]
        public void Step5Next(object sender, EventArgs args)
        {
            if (MoveToNextWorkflow != null)
            {
                MoveToNextWorkflow(this, EventArgs.Empty);
            }
        }

        #endregion

        #region private

        private void InitializeComponent()
        {
            // 
            // Workflow
            // 
            SetDesignerItemLocation(typeof (Start), new Point(479, 10));
            AssociateWorkflowItem(typeof (Start), typeof (NavigationView), "");
            SetDesignerItemLocation(typeof (NavigationView), new Point(451, 130));
            AssociateWorkflowItem(typeof (NavigationView), typeof (Step1), "action://NavigationView/ForwardToNextView");
            SetDesignerItemLocation(typeof (Step1), new Point(494, 285));
            AssociateWorkflowItem(typeof (Step1), typeof (Step2), "action://Step1/nextButton/Click");
            SetDesignerItemLocation(typeof (Step2), new Point(504, 378));
            AssociateWorkflowItem(typeof (Step2), typeof (Step1), "action://Step2/previousButton/Click");
            AssociateWorkflowItem(typeof (Step2), typeof (Step3), "action://Step2/nextButton/Click");
            SetDesignerItemLocation(typeof (Step3), new Point(502, 478));
            AssociateWorkflowItem(typeof (Step3), typeof (Step2), "action://Step3/previousButton/Click");
            AssociateWorkflowItem(typeof (Step3), typeof (Step4), "action://Step3/nextButton/Click");
            SetDesignerItemLocation(typeof (Step4), new Point(504, 574));
            AssociateWorkflowItem(typeof (Step4), typeof (Step3), "action://Step4/previousButton/Click");
            AssociateWorkflowItem(typeof (Step4), typeof (Step5), "action://Step4/nextButton/Click");
            SetDesignerItemLocation(typeof (Step5), new Point(558, 685));
            AssociateWorkflowItem(typeof (Step5), typeof (Step4), "action://Step5/previousButton/Click");
            // 
            // Actions
            // 
            ActionSenders.Add(new MetaActionSender(this, "MoveToNextWorkflow", this, "",
                                                   "action://MainWorkflow/MoveToNextWorkflow"));
            RegisterActionSenders();
        }

        #endregion
    }
}